Repository navigation
fix: check, snapshot and renders use the pinned Chrome, not an older one another tool cached - #5900
Conversation
somanshreddy
left a comment
There was a problem hiding this comment.
Reviewed at 3209128e. No blocker, so I'm approving. There's one behaviour change worth knowing about, below.
What I checked
- Lookup order:
findFromCachenow reads our pinned cache, then a Puppeteer-cache dir only when its build equalsmanagedChromeVersion(). That carries the macOS 12 pin (150) over without the ceiling helper. The env overrides (HYPERFRAMES_BROWSER_PATH,PRODUCER_HEADLESS_SHELL_PATH) still come first. A stale pinned path still flows through asours, sostaleHyperframesCachePathre-download behaviour is unchanged. - Tests:
manager.test.tspasses 59 of 59, andtsc --noEmitis clean. The import that's left,chromeMajorCeiling, is still used atmanagedChromeVersion. - Mutation check: I restored the old order (Puppeteer cache first) and dropped the build match. 4 tests fail: the pinned-over-Puppeteer case, the lone-121 case, "never uses a puppeteer-cache shell at another build", and the macOS 12 "skips newer than 150".
- Shipped images:
packages/gcp-cloud-run/Dockerfile(148),packages/cli/src/docker/Dockerfile.render(@stable) andexamples/k8s-jobsall install into the Puppeteer cache at a build other than 152. But they all exportPRODUCER_HEADLESS_SHELL_PATH, orHYPERFRAMES_CHROME_PATHplusPRODUCER_…, so the env override wins and they don't change.
Behaviour change (intended, as far as I can tell; not a blocker)
A user who deliberately installed chrome-headless-shell with npx @puppeteer/browsers install at any build other than the pin, and has no HyperFrames cache, used to get that binary for check/snapshot. Now they get system Chrome, or a pinned download of about 100 MB on first run. That reverses the "respect an explicit prior choice" rule the old comment described. I found no doc that promised it, and HYPERFRAMES_BROWSER_PATH is still the escape hatch. A one-line debuglog saying "skipping puppeteer-cache
doctor output.
Dockerfile.testputs 148 in the Puppeteer cache and sets onlyPUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium. So any CLIcheck/snapshotrun inside that image now resolves differently, to system chromium or a download instead of the cached 148. CI on that image will show whether anything there depends on it.
CI was still running at the time of review, with 0 failing.
— Somu
…another tool cached
b50e1cd to
45b1ab3
Compare
somanshreddy
left a comment
There was a problem hiding this comment.
Re-reviewed at a0bfd144. This is a rebase onto main plus a redesign: the engine now follows the same pinned-first rule, and shared shells are tried with --version. Requesting changes: the engine doesn't compile.
Blocker: missing imports in packages/engine/src/services/browserManager.ts
The import from ./chromeHostCeiling.js brings in only chromeMajorCeiling, exceedsChromeCeiling and isManagedChromeDir, but the file uses two more names:
pickSharedShell(line 220, infindSharedHeadlessShell).compareBrowserVersionsDescending(lines 204 and 286, infindCachedHeadlessShellandresolveFullChromePath). The local copy was deleted, and the new export inchromeHostCeiling.tsisn't imported.
Evidence:
tsc --noEmitinpackages/cli, which compiles engine sources, fails with:browserManager.ts(220,51): TS7006(implicit any)browserManager.ts(286,42): TS2304: Cannot find name 'compareBrowserVersionsDescending'
packages/enginebrowserManager.test.tshas 10 failures, including every "selects only the host-compatible cached shell on …" case.- CI:
Producer: unit testsis red, andTypecheckwas still pending at the time of review. - At runtime,
resolveHeadlessShellPaththrows aReferenceErrorfor anyone without an env override, and so doesresolveFullChromePath. The shipped images setPRODUCER_HEADLESS_SHELL_PATH, so they wouldn't hit it, but local and SDK renders would.
The fix should be just adding both names to the import.
On the design, once it compiles (not blocking)
shellStartson Windows (inferred, not run). On Windows, Chrome's--versiondoesn't print-and-exit the way it does on Linux and macOS. Ifchrome-headless-shell.exe --versionkeeps running there,spawnSyncblocks for the full 10 s per non-pinned dir, then reports "doesn't start". So on Windows every non-pinned shared shell would be skipped after a 10 s stall per process. The tests mockspawnSync. One real run onwindows-latestwould settle it.- Engine order changed. Before, any build in our cache came before the Puppeteer cache. Now it's our pinned build, then the shared cache's newest working shell, then any build in our cache. So an engine-only render (SDK or producer used directly, no env override) on a box whose
~/.cache/hyperframesholds an older, non-pinned build now picks a newer shared shell, which can be a Canary someone else installed. That's probably fine, but it's a render-determinism change for that setup, so it's worth a line in the PR. - What's still right: our pinned build comes first in both the CLI and the engine. A shared-cache dir at the pinned build is used without the
--versionprobe. The ceiling skip is kept for macOS 12.
I'll re-review on the next pin.
— Somu
somanshreddy
left a comment
There was a problem hiding this comment.
Re-reviewed at 507bc655. I compared against a0bfd144: range-diff shows commits 1–5 as =, and three commits are new. The blocker is fixed. Approving, which replaces my changes-request.
The four points from my last review
- Missing imports (fixed).
compareBrowserVersionsDescendingandpickSharedShellare now imported inengine/src/services/browserManager.ts. EnginebrowserManager.test.tspasses 90 of 90, CLImanager.test.tspasses 60 of 60, andtsc --noEmitis clean. CI has 61 pass and 0 failing. - The probe (answered).
--no-sandbox --dump-dom about:blankloads a page and exits. I ran it on the three real shells on this Linux box: 144, 152.0.7977.42 and 152.0.7977.54 all exit 0. I didn't run it on Windows. The 10 sspawnSynctimeout still caps any stall, and the result is cached per path. - Engine order change. It's now written up under Behaviour changes in the PR description.
- Skipped shells are now logged. They show up under
NODE_DEBUG=hyperframes:browser.
The caption-script change
hfBrowser()askshyperframes browser path, first throughhfCli(), then through a globalhyperframes. If both fail, it falls back to system Chrome as before. Each attempt is in atry, andfsis in scope.hf-cli.test.mjspasses.- Skill/CLI version skew. Skills ship on merge. An older CLI without
browser pathwould print help or an error; the last line isn't an existing file, so the script falls back to system Chrome. Nothing breaks. - Nit:
browser pathruns a fullensureBrowser()when nothing is found, so on a machine with no Chrome at all, the first caption-script call now downloads the pinned shell (about 100 MB). It's synchronous, with no timeout and stderr ignored, so it looks like a hang. Atimeouton theexecFileSync, or callingfindBrowseronly, would avoid that. This only affects a machine with no browser, which previously launched nothing useful anyway. - Caption measurement now uses headless shell instead of full Chrome. That matches what renders use, which is the point, but
measure-layoutresults may shift slightly on machines that used to measure with system Chrome.
— Somu
Edit accuracy: accurate 271 (base branch 271), smooth 163 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
What
One rule now decides which
chrome-headless-shellHyperFrames launches, in the CLI and in the engine:~/.cache/hyperframes/chrome), then the shared Puppeteer cache (~/.cache/puppeteer/chrome-headless-shell). The pinned build is 152, or 150 on macOS 12.--no-sandbox --dump-dom about:blank) and exits 0. It is probed once per path per process, with a 10 s limit, and the macOS 12 ceiling still applies. A skipped shell is logged underNODE_DEBUG=hyperframes:browser.So an old shell that dies at launch is skipped, and a working stable shell (what
npx @puppeteer/browsers install chrome-headless-shellputs there, as the CLI's own Linux hint suggests) is still used.Why
A field report: on a Mac where another tool had once installed Puppeteer's
chrome-headless-shell121,hyperframes snapshotandcheckfailed withnet::ERR_ABORTEDathttp://127.0.0.1:<port>/.hyperframes doctorshowed the cachedmac_arm-121shell dying with SIGTRAP on--version, and settingHYPERFRAMES_BROWSER_PATHto system Chrome fixed it.The cause is the lookup order in
findFromCache. It took the newest version directory in the shared Puppeteer cache, whatever its age, before looking at the pinned build in~/.cache/hyperframes/chrome. "Usable" only meant a non-empty file, so a 121 that cannot start beat a working 152.renderwas not affected: it already asks for the pinned build (preferManagedChrome).Related work
None open.
How
Every Chrome launch, and where it gets its binary:
renderensureBrowser({ preferManagedChrome })(preflight.ts), handed to the engine asPRODUCER_HEADLESS_SHELL_PATH(commands/render.ts), read first byresolveHeadlessShellPathserver/studioServer.ts)check,snapshot,capture,layout, motion shotsensureBrowser(), passed asexecutablePathto its own launchbenchmark, a standalone producer, the Lambda handlerresolveHeadlessShellPath), which scanned the shared cache newest-first on its ownSo the engine's resolver gets the same rule:
@hyperframes/engine/chrome-host-ceiling, which the CLI already imported:managedChromeVersion,isManagedChromeDirandcompareBrowserVersionsDescendingmove there.shellStartsloads a blank page once per path.--dump-domis headless Chrome's own print-and-exit mode on every platform, and it goes through the launch an old build dies in.--versionwas the first probe, but on Windows it may not exit, which would stall every non-pinned shell for the full limit.pickSharedShellreturns the shared cache's pinned build, else its newest starting shell.resolveHeadlessShellPath: the pinned build in our cache, thenpickSharedShellon the shared cache. With neither, the newest build of ours, since the engine cannot download.findFromCachereads the pinned cache first, then the Puppeteer cache.findFromPuppeteerCacheusespickSharedShell. The CLI's own copy of the version sort (parseVersionSegments,compareVersionDirsDescending) is gone in favour of the engine's.HYPERFRAMES_BROWSER_PATHandPRODUCER_HEADLESS_SHELL_PATHcome first, unchanged.preview-frames,check-overflow,check-rail-climax,measure-layout) launch whathyperframes browser pathprints (hfBrowserinhf-cli.cjs), so they follow the same rule. Before, each hardcoded system Chrome. Without a CLI they still use system Chrome.Behaviour changes
chrome-headless-shellwithnpx @puppeteer/browsers installand has no HyperFrames cache still gets it, if it starts. Only a shell that fails to start is skipped.Test plan
packages/cli/src/browser/manager.test.ts.121.0.6167.85beside the pinned cache resolves to the pinned build.packages/engine/src/services/browserManager.test.ts.linux-121.0.6167.85that does not start resolves to nothing, where main returns the 121.skills/embedded-captions/scripts/hf-cli.test.mjs: the scripts launch the path a stub CLI prints forbrowser path. It fails on main (hfBrowseris not a function).tsc --noEmitand the browser tests at this head: CI runs them.chrome-headless-shell121.0.6167.85 dies with SIGTRAP on both--versionand--dump-dom about:blank. The pinned 152.0.7977.30 prints its version and an empty page on both.--dump-dom, which exits there too; that is inferred from Chrome's headless mode, not run.